package pro.lepers.portfolio.view {
	import fr.digitas.flowearth.conf.Conf;
	import fr.digitas.flowearth.ui.layout.Layout;
	import fr.digitas.flowearth.ui.layout.renderer.LeftRenderer;
	import fr.digitas.flowearth.ui.text.StyledLabel;

	import flash.display.Sprite;
	import flash.events.Event;
	import flash.geom.Rectangle;

	/**
	 * @author plepers
	 */
	public class Footer extends Sprite {
		
		
		public function Footer () {
			buildLayout();
			buildItems();
			addEventListener( Event.ADDED_TO_STAGE, onAdded );
			addEventListener( Event.REMOVED_FROM_STAGE, onRemoved );
		}

		private function onAdded( e : Event ) : void {
			stage.addEventListener( Event.RESIZE, onResize );
			onResize( null );
		}
		
		private function onRemoved( e : Event ) : void {
			stage.removeEventListener( Event.RESIZE, onResize );
		}

		private function onResize(event : Event) : void {
			y = stage.stageHeight;
		}

		private function buildItems ( ) : void {
			
			var datas : XML = Conf.getDatas( "footer" );
			
			var list : XMLList = datas.item;
			
			var fitem : StyledLabel;
			
			for each (var fid : XML in list) {
				fitem = new StyledLabel( );
				fitem.styleName = ".footer_item";
				fitem.text = fid.text( );
				_layout.addChild( fitem );
			}
		}
		
		
		private function buildLayout() : void {
			_layout = new Layout( );
			_layout.renderer = new LeftRenderer( );
			_layout.margin = new Rectangle( 15 );
			_layout.y = -18;
			addChild( _layout );
		}
		
		private var _layout : Layout;
	}
}
